/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-04-28
 * Time:23:25
 */
public class 按奇偶排序数组 {
    class Solution {
        public int[] sortArrayByParity(int[] nums) {
            int n = nums.length, index = 0;
            int[] res = new int[n];
            for (int num : nums) {
                if (num % 2 == 0) {
                    res[index++] = num;
                }
            }
            for (int num : nums) {
                if (num % 2 == 1) {
                    res[index++] = num;
                }
            }
            return res;
        }
    }
}
